<template>
	<view class="container">
		

		<view class="tui-box">
			
			<view class="tui-top tui-goods-info">
				<tui-list-cell :hover="false" :lineLeft="0">
					<view class="tui-goods-title">订单编号: SN{{orderInfo.id}}</view>
				</tui-list-cell>
				<block>
					<tui-list-cell :hover="false" padding="0">
						<view class="tui-goods-item">
							<image :src="goodsInfo.img_logo" class="tui-goods-img"></image>
							<view class="tui-goods-center">
								<view class="tui-goods-name">{{goodsInfo.name}}</view>
								<view class="tui-goods-attr"></view>
							</view>
							<view class="tui-price-right">
								<view>￥{{orderInfo.goods_money}}</view>
								<view>x{{orderInfo.goods_num}}</view>
							</view>
						</view>
					</tui-list-cell>
				</block>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>订单总额</view>
						<view>￥{{orderInfo.money_total}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>支付方式</view>
						<view>{{orderInfo.pay_type_name}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>订单状态</view>
						<view>{{orderInfo.status_name}}</view>
					</view>
				</tui-list-cell>
				
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>下单时间</view>
						<view>{{orderInfo.add_time}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell v-if="false" :arrow="false" :hover="hasCoupon" >
					<view class="tui-padding tui-flex">
						<view>优惠券</view>
						<view>{{orderInfo.coupon_remark || '没有可用优惠券'}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell v-if="false" :hover="true" :arrow="true">
					<view class="tui-padding tui-flex">
						<view>发票</view>
						<view class="tui-invoice-text">不开发票</view>
					</view>
				</tui-list-cell>
			</view>

			<view class="tui-top">
				
				<tui-list-cell :hover="false" :arrow="false">
					<view class="tui-padding tui-flex">
						<view>配送地址</view>
						<view class="tui-invoice-text">{{shipInfo.express_code}}</view>
					</view>
				</tui-list-cell>
				
				<tui-list-cell :arrow="false">
					<view class="tui-address">
						<view class="tui-userinfo">
							<text class="tui-name">{{shipInfo.name}}</text>
							{{shipInfo.phone}}
						</view>
						<view class="tui-addr">
							<text>{{shipInfo.address}}</text>
						</view>
					</view>
					<view class="tui-bg-img"></view>
				</tui-list-cell>
			</view>
			
			
			<view class="tui-addr-box">
				<form :report-submit="true">
					
					<!-- <tui-list-cell :hover="false" padding="0">
						<view class="tui-line-cell">
							<view class="tui-title">物流公司</view>
							<input placeholder-class="tui-phcolor" class="tui-input" name="remark" v-model="expressCode"
								placeholder="中通快递 申通快递 顺丰快递" maxlength="50" type="text" />
						</view>
					</tui-list-cell> -->
					
					<tui-list-cell :hover="false" padding="0">
						<view class="tui-line-cell">
							<view class="tui-title">物流公司</view>
							<picker @change="bindPickerChange" :value="expressIndex" :range="expressList">
								<view class="uni-input">{{expressList[expressIndex]}}</view>
							</picker>
						</view>
					</tui-list-cell>
					
					<tui-list-cell :hover="false" padding="0">
						<view class="tui-line-cell">
							<view class="tui-title">快递单号</view>
							<input placeholder-class="tui-phcolor" class="tui-input" v-model="postCode"
								placeholder="示例: SF1019292" maxlength="50" type="text" />
						</view>
					</tui-list-cell>
					<view class="tui-addr-save" @click="postOrderShip()">
						<tui-button type="green" height="88rpx">确认发货</tui-button>
					</view>
			
				</form>
			</view>
			
		</view>
		
		
		<view class="tui-protocol" hover-class="opcity" :hover-stay-time="150">
			<text class="tui-protocol-red">用户自提的话，可以填自提，方便用户查看信息~</text>
			<br><br>
			<text class="tui-protocol-red">快递单号填错的，请联系平台修改</text>
			<br><br>
			<text class="tui-protocol-red">请谨慎操作</text>
			<br><br><br><br><br><br>
		</view>
		
		
		<view class="tui-safe-area"></view>
		
		<footer-menu :tabCur="2"></footer-menu>
		
	</view>
</template>

<script>
	import footerMenu from "@/components/footer-menu.vue"
	import tuiIcon from "@/components/thorui/tui-icon/tui-icon.vue"
	import tuiButton from "@/components/thorui/tui-button/tui-button"
	import tuiListView from "@/components/thorui/tui-list-view/tui-list-view"
	import tuiListCell from "@/components/thorui/tui-list-cell/tui-list-cell"
	import tuiBottomPopup from "@/components/thorui/tui-bottom-popup/tui-bottom-popup"
	import tuiModal from "@/components/thorui/tui-modal/tui-modal"
	import tuiTag from "@/components/thorui/tui-tag/tui-tag"
	export default {
		components: {
			tuiButton,
			tuiListView,
			tuiListCell,
			tuiBottomPopup,
			tuiModal,
			footerMenu,
			tuiIcon,
			tuiTag,
		},
		data() {
			return {
				
				orderId: 0,
				orderInfo: [],
				goodsList: [],
				goodsInfo: [],
				shipInfo: [],
				
				expressCode: "",		
				postCode: "",	
					
				expressList: ['同城快递'],
				expressIndex: 0,

			}
		},
		
		methods: {
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.detail.value)
				this.expressIndex = e.detail.value
			},
			
	
			goMyOrderExpressInfo: function(){
				return false;
				uni.navigateTo({
					url: '/pages/my-order/express-info?order_id='+ this.orderId
				})
			},
			
			//得到订单的详情
			getExpressList: function() {
				uni.request({
					url: this.$apiUrl + '/api/common/expressList',
					header: {
						'userId': uni.getStorageSync('userId'),
						'userToken': uni.getStorageSync('userToken'),
						'shopId': uni.getStorageSync('shopId')
					},
					success: (res) => {
						let resData = res.data['data'];
						let resError = res.data['error'];
						let resMsg = res.data['msg'];
						
						this.expressList = resData;
					}
				});
			},

			//得到订单的详情
			getOrderInfo: function() {
				uni.request({
					url: this.$apiUrl + '/api/order/authOrderInfo',
					header: {
						'userId': uni.getStorageSync('userId'),
						'userToken': uni.getStorageSync('userToken'),
						'shopId': uni.getStorageSync('shopId')
					},
					data: { order_id: this.orderId},
					success: (res) => {
						let resData = res.data['data'];
						let resError = res.data['error'];
						let resMsg = res.data['msg'];
						if(resError) { this.tui.toast(resMsg); return; }
						
						this.orderInfo = resData['order_info'];
						this.goodsInfo = resData['goods_info'];
						this.shipInfo = resData['ship_info'];
						this.postCode = this.shipInfo.post_code || '';
						this.expressIndex = this.shipInfo.express_code_idx || 0;
					}
				});
			},
			
			postOrderShip: function(){
				uni.request({
					url: this.$apiUrl + '/api/order/shopAuthShip',
					header: {
						'userId': uni.getStorageSync('userId'),
						'userToken': uni.getStorageSync('userToken'),
						'shopId': uni.getStorageSync('shopId')
					},
					data: {
						order_id: this.orderId,
						express_code: this.expressCode,
						express_code_idx: this.expressIndex,
						post_code: this.postCode
					},
					success: (res) => {
						let resErr = res.data['error'];
						let resMsg = res.data['msg'];
						this.tui.toast(resMsg);
						if(resErr == 0 ){		//发送成功的时候
							setTimeout(() => {
								uni.navigateTo({
									url: "/pages/shop/auth-order"
								})
							}, 1000)
						}
					}
				});
				
			}
		},
		
		//页面加载的时候
		onLoad: function(options) {
			this.orderId = options.id || 0;
			this.getOrderInfo();
			this.getExpressList();
		},
	}
</script>

<style>
	
	
	.container {
		padding-bottom: 98rpx;
	}

	.tui-box {
		padding: 0 0 118rpx;
		box-sizing: border-box;
	}

	.tui-address {
		min-height: 80rpx;
		padding: 10rpx 0;
		box-sizing: border-box;
		position: relative;
	}

	.tui-userinfo {
		font-size: 30rpx;
		font-weight: 500;
		line-height: 30rpx;
		padding-bottom: 12rpx;
	}

	.tui-name {
		padding-right: 40rpx;
	}

	.tui-addr {
		font-size: 24rpx;
		word-break: break-all;
		padding-right: 25rpx;
	}

	.tui-addr-tag {
		padding: 5rpx 8rpx;
		flex-shrink: 0;
		background: #EB0909;
		color: #fff;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		font-size: 25rpx;
		line-height: 25rpx;
		transform: scale(0.8);
		transform-origin: 0 center;
		border-radius: 6rpx;
	}

	.tui-bg-img {
		position: absolute;
		width: 100%;
		height: 8rpx;
		left: 0;
		bottom: 0;
		background: url("") repeat;
	}

	.tui-top {
		margin-top: 20rpx;
		overflow: hidden;
	}

	.tui-goods-title {
		font-size: 28rpx;
		display: flex;
		align-items: center;
	}

	.tui-padding {
		box-sizing: border-box;
	}

	.tui-goods-item {
		width: 100%;
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
	}

	.tui-goods-img {
		width: 180rpx;
		height: 180rpx;
		display: block;
		flex-shrink: 0;
		border-radius: 6rpx;
	}

	.tui-goods-center {
		flex: 1;
		padding: 20rpx 8rpx;
		box-sizing: border-box;
	}

	.tui-goods-name {
		max-width: 310rpx;
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		font-size: 26rpx;
		line-height: 32rpx;
	}

	.tui-goods-attr {
		font-size: 22rpx;
		color: #888888;
		line-height: 32rpx;
		padding-top: 20rpx;
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}

	.tui-price-right {
		text-align: right;
		font-size: 24rpx;
		color: #888888;
		line-height: 30rpx;
		padding-top: 20rpx;
	}

	.tui-flex {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 26rpx;
	}
	.tui-total-flex{
		justify-content: flex-end;
	}

	.tui-color-red,
	.tui-invoice-text {
		color: #E41F19;
		padding-right: 30rpx;
	}

	.tui-balance {
		font-size: 28rpx;
		font-weight: 500;
	}

	.tui-black {
		color: #222;
		line-height: 30rpx;
	}

	.tui-gray {
		color: #888888;
		font-weight: 400;
	}

	.tui-light-dark {
		color: #666;
	}

	.tui-goods-price {
		display: flex;
		align-items: center;
		padding-top: 20rpx;
	}

	.tui-size-26 {
		font-size: 26rpx;
		line-height: 26rpx;
	}

	.tui-price-large {
		font-size: 34rpx;
		line-height: 32rpx;
		font-weight: 600;
	}

	.tui-flex-end {
		display: flex;
		align-items: flex-end;
		padding-right: 0;
	}

	.tui-phcolor {
		color: #B3B3B3;
		font-size: 26rpx;
	}

	/* #ifndef H5 */
	.tui-remark-box {
		padding: 22rpx 30rpx;
	}

	/* #endif */
	/* #ifdef H5 */
	.tui-remark-box {
		padding: 26rpx 30rpx;
	}

	/* #endif */

	.tui-remark {
		flex: 1;
		font-size: 26rpx;
		padding-left: 64rpx;
	}

	.tui-scale-small {
		transform: scale(0.8);
		transform-origin: 100% center;
	}

	.tui-scale-small .wx-switch-input {
		margin: 0 !important;
	}

	/* #ifdef H5 */
	>>>uni-switch .uni-switch-input {
		margin-right: 0 !important;
	}

	/* #endif */
	.tui-tabbar {
		width: 100%;
		height: 98rpx;
		background: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		font-size: 26rpx;
		box-shadow: 0 0 1px rgba(0, 0, 0, .3);
		padding-bottom: env(safe-area-inset-bottom);
		z-index: 999;
	}

	.tui-pr-30 {
		padding-right: 30rpx;
	}

	.tui-pr-20 {
		padding-right: 20rpx;
	}

	.tui-none-addr {
		height: 80rpx;
		padding-left: 5rpx;
		display: flex;
		align-items: center;
	}

	.tui-addr-img {
		width: 36rpx;
		height: 46rpx;
		display: block;
		margin-right: 15rpx;
	}


	.tui-pr25 {
		padding-right: 25rpx;
	}

	.tui-safe-area {
		height: 1rpx;
		padding-bottom: env(safe-area-inset-bottom);
	}
	
	
	.tui-top-refund {
		width: 80%;
		margin-top: 80rpx;
		margin-left: 10%;
		overflow: hidden;
	}
	
	
	
	/*Model 弹窗*/
	.tui-modal-custom {
		text-align: center
	}

	.tui-modal-custom-text {
		font-size: 30rpx;
		color: #333;
		padding: 30rpx 0
	}

	.tui-prompt-title {
		padding-bottom: 20rpx;
		font-size: 34rpx;
	}

	.tui-input {
		margin: 30rpx 20rpx;
		border-bottom: 1rpx solid #E6E6E6;
		padding-bottom: 20rpx;
		font-size: 32rpx;
	}
	
	
	
	.pay-type-list {
		margin-top: 40rpx;
		background-color: #fff;
		margin-bottom: 80rpx !important;
	}
	
	.pay-type-icon{
		width: 100rpx;
		font-size: 52rpx;
	}
	
	.pay-type-tit{
		font-size: 36rpx;
		color: #222;
		margin-bottom: 4rpx;
	}
	
	




	.tui-addr-box {
		padding: 10rpx 0;
	}

	.tui-line-cell {
		width: 100%;
		padding: 10rpx 30rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}

	.tui-title {
		width: 180rpx;
		font-size: 28rpx;
	}


	.tui-input {
		width: 500rpx;
	}


	.tui-phcolor {
		color: #ccc;
		font-size: 28rpx;
	}

	.tui-cell-title {
		font-size: 28rpx;
	}

	.tui-addr-label {
		margin-left: 70rpx;
	}


	.tui-label-active {
		background: #E41F19;
		border-color: #E41F19;
		color: #fff;
	}

	.tui-swipe-cell {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background: #fff;
		padding: 10rpx 24rpx;
		border-radius: 6rpx;
		overflow: hidden;
		font-size: 28rpx;
	}

	.tui-addr-save {
		padding: 24rpx;
		margin-top: 100rpx;
	}


	.tui-protocol {
		color: #333;
		font-size: 24upx;
		text-align: center;
		width: 100%;
		margin-top: 29upx;
	}

	.tui-protocol-red {
		color: #f54f46;
	}
	
	.qr-code{
		width: 750rpx;
		height: 1020rpx;
	}
	
	.tui-right-del{
		margin:20rpx 20rpx 100rpx 500rpx;
		padding: 40rpx;
		
	}
	
	
</style>